/* JavaLog - package tracker 
* 
* Copyright (C) 2009 Allyson Lima, Diego Pedro, Victor Freire
* 
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software 
* Foundation, either version 3 of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along with this 
* program. If not, see <http://www.gnu.org/licenses/>.
*/

package br.edu.ufcg.ccc.javalog;

/**
* Stub for Address class.
* @author Allyson Lima, Diego Pedro, Victor Freire
* @version 12/10/09
*/
public class Address {
	
	/**
	 * Region address attribute
	 */
	private String region;
	
	/**
	 * State address attribute
	 */
	private String state;
	
	/**
	 * City address attribute
	 */
	private String city;
	
	/**
	 * District address attribute
	 */
	private String district;
	
	/**
	 * Zip Code address attribute
	 */
	private String zipCode;
	
	/**
	 * Street address attribute
	 */
	private String street;
	
	/**
	 * Number address attribute
	 */
	private String number;
	
	/**
	 * Constructor for Address Class
	 * @param region - region to the address
	 * @param state - state to the address
	 * @param city - city to the address
	 * @param district - district to the address
	 * @param zipCode - zipCode to the address
	 * @param street - street to the address
	 * @param number - number to the address
	 */
	public Address(String region, String state, String city, String district,
			String zipCode, String street, String number) {
		this.region = region;
		this.state = state;
		this.city = city;
		this.district = district;
		this.zipCode = zipCode;
		this.street = street;
		this.number = number;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	
	//STUBS
	
	public void setAddress(Address adr) {}
	
	@Override
	public String toString() {
		 return String.format("Região: %s%nEstado: %s%nCidade:%s%n Bairro:%s%nCEP:%s%nEndereço: %s%nNúmero: %s%n",
				region, state, city, district, zipCode, street, number);
	}
	
	private boolean equalFields(String s1, String s2) {
		if(s1.equals("*") || s2.equals("*")) return true;
		return s1.equals(s2); 
	}
	
	@Override
	public boolean equals(Object obj) {
		// TODO add wildcard
		if(this == obj) return true;
		if(obj == null || getClass() != obj.getClass()) return false;
		Address addr = (Address) obj;
		return (equalFields(getRegion(), addr.getRegion())
				&& equalFields(getState(), addr.getState())
				&& equalFields(getCity(), addr.getCity())
				&& equalFields(getDistrict(), addr.getDistrict())
				&& equalFields(getZipCode(), addr.getZipCode())
				&& equalFields(getStreet(), addr.getStreet())
				&& equalFields(getNumber(), addr.getNumber()));
	}
	
	@Override
	public int hashCode() {
		// TODO FIX THIS HASHCODE!
		return 0;
	}
}
